package com.by.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api")
@RefreshScope// 自动更新配置中心的配置
public class UserController {


    @Value("${db.username}")
    String username;

    @Value("${db.password}")
    String password;

    @Value("${db.url}")
    String url;


    @GetMapping("/user")
    public Map query() {
        Map map = new HashMap();
        map.put("username", username);
        map.put("password", password);
        map.put("url", url);
        return map;
    }
}
